package com.${sysEname}.controller;
import com.apache.api.api.ApiService;
import com.apache.ius.common.annotion.AnnotationUtil;
import com.apache.ius.controller.SuperTransAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Map;

/**
 * 平台自动生成的统一控制controller类
 * @Date ${.now}
 */
@Controller
public class TransAction extends SuperTransAction {

    @Autowired(required = false)
    @Qualifier("${sysEname}Service")
    private ApiService ${sysEname}Service;

    /**
     * 初始化方法
     * @throws Exception
     */
    @ModelAttribute
    public void populateModel() throws Exception {
        if(this.iusService==null) {
            this.setIusService(${sysEname}Service);
        }
        if(!AnnotationUtil.isScanning){
            //自动扫描包(拦截器专用)
            AnnotationUtil.getInstance().loadCalssBean("com.apache.ius");
        }
    }

    /**
    * 跳到ius管理后台首页面
    */
    @RequestMapping(value = "/ius", method = RequestMethod.GET)
        public ModelAndView index(HttpServletRequest request) throws ServletException, IOException {
        ModelAndView model = new ModelAndView();
        Map<String, Object> defMap = super.getDefaultDataMap(request);//获取freemark模板所需变量
        model.addAllObjects(defMap);
        model.setViewName("/WEB-INF/pages/plateform/admin/index-home-sys");//指定跳转页面地址，根目录=配置文件spring.mvc.view.prefix值
        return model;
    }

}

